<style>
  #box{
width: 100px;
height: 100px;
background-color: aqua;
position: absolute;left: 0;top: 0;
  }
</style>
<body>
    <div id="box" ></div>
</body>
<script>
      var obox = document.getElementById('box')

      document.onkeydown = function(eve){
        var e =eve || window.event;
        var code = e.keyCode || e.window;
        switch(code){
            case 37:
               obox.style.left = obox.offsetLeft - 10 + 'px' ;break;
            case 38:
               obox.style.top = obox.offsetTop - 10 + 'px' ;break;
            case 39:
               obox.style.left = obox.offsetLeft + 10 + 'px' ;break;
            case 40:
               obox.style.top = obox.offsetTop + 10 + 'px' ;break;
        }
      }
</script>